home *** CD-ROM | disk | FTP | other *** search
- function ExtractName(const Filename: String): String;
- { from my XProcs library }
- var aExt : String;
- aPos : Integer;
- begin
- aExt := ExtractFileExt(Filename);
- Result := ExtractFileName(Filename);
- if aExt <> '' then begin
- aPos:=Pos(aExt,Result);
- if aPos>0 then Delete(Result,aPos,Length(aExt));
- end;
- end;
-
- procedure CheckProcedures(aDb: TDataBase);
- var
- aPath : String;
- aSearch : TSearchRec;
- aResult : Integer;
- aProcs : TStringList;
- procedure UpdateSql(const aFile: String);
- var aProc: String;
- i: Integer;
- begin
- if FileExists(aFile) then begin
- aProc:=ExtractName(aFile);
- with TQuery.Create(nil) do
- try
- DataBaseName := aDb.DataBaseName;
- if aProcs.Find(aProc,i) then begin
- SQL.Add(Format('DROP PROCEDURE %s',[aProc]));
- ExeSQL;
- end;
- ParamCheck := False;
- SQL.LoadFromFile(aFile);
- ExecSQL;
- finally
- Free;
- end;
- end;
- end;
- begin
- aPath := ExtractFilePath(ParamStr(0))+'sql\';
- aProcs := TStringList.Create;
- try
- aProcs.Sorted := True;
- Session.GetStoredProcNames(aDb.DataBaseName, aProcs);
- aResult := FindFirst(aPath+'*.sql',faAnyFile,aSearch);
- while aResult = 0 do begin
- UpdateSQL(aPath+aSearch.Name);
- aResult := FindNext(aSearch);
- end;
- FindClose(aSearch);
- finally
- aProcs.Free;
- end;
- end;